package mypractice;

import java.util.Scanner;

public class Leetcode345 {
    public static void main(String[] args) {
/*        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();*/
        String s = "hello";
        s=reverseVowels(s);
        System.out.println(s);
    }


    public static String reverseVowels(String s) {
        int sLen = s.length();
        int left = 0, right = sLen - 1;
        char isA, isB;
        StringBuilder sb = new StringBuilder(s);
        while (left < right) {
            // 判断是否是元音字母
            while (left < right && !isNot(s.charAt(left))) {
                left++;
            }

            while (left < right && !isNot(s.charAt(right))) {
                right--;
            }
            // 交换
            if (left < right) {
                char temp = s.charAt(left);
                sb.setCharAt(left, s.charAt(right));
                sb.setCharAt(right, temp);
                left++;
                right--;
            }else{
                break;
            }
        }
        s = sb.toString();
        return s;
    }

    public static boolean isNot(char c) {

        switch (c) {
            case 'a':
                return true;
            case 'e':
                return true;
            case 'i':
                return true;
            case 'o':
                return true;
            case 'u':
                return true;
        }
        return false;
    }

}
